def get_max_repetitions(s1, n1, s2, n2):
    def __sup(l1, l2):  # 辅助判断l2是否可以由l1生成
        for i in range(len(l1)):
            if len(l2) != 0 and l1[i] == l2[-1]:
                l2.pop()
        return len(l2) == 0

    s1 = [i for i in s1][::-1] * n1
    s2 = [i for i in s2] * n2
    m = len(s1) // len(s2)

    while m > 0:
        s22 = s2 * m
        if __sup(s1, s22) is True:
            return m
        m -= 1

    return 0


if __name__ == '__main__':
    # print(get_max_repetitions("aaa", 3, "aa", 1))
    print(get_max_repetitions("acb", 1, "acb", 1))
    # print(get_max_repetitions("acb", 4, "ab", 2))
